package home

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"telemple_web/app"
	"telemple_web/app/http/models"
)

func Index(ctx *gin.Context) {
	//ctx.JSON(http.StatusOK, map[string]any{
	//	"code":    0,
	//	"success": true,
	//	"message": "success",
	//	"data":    map[string]any{"des": "hello world"},
	//})

	var res []models.User
	//err := app.DBR().Debug().Find(&res).Error
	err := app.DBR().Find(&res).Error
	if err != nil {
		ctx.JSON(http.StatusOK, map[string]any{
			"code":    -1,
			"success": false,
			"message": err.Error(),
			"data":    map[string]any{"des": "hello world"},
		})
		return
	}
	ctx.JSON(http.StatusOK, map[string]any{
		"code":    0,
		"success": true,
		"message": "success",
		"data":    res,
	})

}
